package com.ruoyi.lclook.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lclook.domain.LcOffline;
import com.ruoyi.lclook.service.ILcOfflineService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 线下项目Controller
 * 
 * @author Choi
 * @date 2021-08-07
 */
@RestController
@RequestMapping("/lclook/offline")
public class LcOfflineController extends BaseController
{
    @Autowired
    private ILcOfflineService lcOfflineService;

    /**
     * 查询线下项目列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:offline:list')")
    @GetMapping("/list")
    public TableDataInfo list(LcOffline lcOffline)
    {
        startPage();
        List<LcOffline> list = lcOfflineService.selectLcOfflineList(lcOffline);
        return getDataTable(list);
    }

    /**
     * 导出线下项目列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:offline:export')")
    @Log(title = "线下项目", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LcOffline lcOffline)
    {
        List<LcOffline> list = lcOfflineService.selectLcOfflineList(lcOffline);
        ExcelUtil<LcOffline> util = new ExcelUtil<LcOffline>(LcOffline.class);
        return util.exportExcel(list, "线下项目数据");
    }

    /**
     * 获取线下项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('lclook:offline:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lcOfflineService.selectLcOfflineById(id));
    }

    /**
     * 新增线下项目
     */
    @PreAuthorize("@ss.hasPermi('lclook:offline:add')")
    @Log(title = "线下项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LcOffline lcOffline)
    {
        return toAjax(lcOfflineService.insertLcOffline(lcOffline));
    }

    /**
     * 修改线下项目
     */
    @PreAuthorize("@ss.hasPermi('lclook:offline:edit')")
    @Log(title = "线下项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LcOffline lcOffline)
    {
        return toAjax(lcOfflineService.updateLcOffline(lcOffline));
    }

    /**
     * 删除线下项目
     */
    @PreAuthorize("@ss.hasPermi('lclook:offline:remove')")
    @Log(title = "线下项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lcOfflineService.deleteLcOfflineByIds(ids));
    }
}
